/**
 * 
 */
package com.honghao.student.util;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;

import org.apache.commons.lang.StringUtils;
import com.honghao.student.constans.StudentConstans;
/**
 * @author honghao.li
 */
public final class CommonUtils {
	/**
	 * 读取系统额外配置文件 ResourceBundle 读取支持国际化 这里使用ClassLoader
	 * @param proName
	 * @param constans
	 * @param key
	 * @return
	 * @throws IOException
	 */
	public static List<String> getValue4Pro(String proName,
			StudentConstans constans, String... key) throws IOException {
		if (StringUtils.isEmpty(proName))
			throw new RuntimeException(proName + "is not found");
		Properties pro = new Properties();
		pro.load(CommonUtils.class.getClassLoader()
				.getResourceAsStream(proName));
		List<String> str = new ArrayList<String>();
		switch (constans) {
			case ALLPRO:
				for (Object k : pro.keySet()) {
					str.add(pro.getProperty((String)k));
				}
				break;
			case PARTPRO:
				for (String s : key) {
					str.add(pro.getProperty(s));
				}
				break;
			default:
					str.add(pro.getProperty(key[0]));
				break;
		}
		return str;
	}
}
